package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: WangHongKun
 * @Date: 2022/9/22 16:58
 * @Email: 2028911483@qq.com
 * @Phone: 18683977706
 */

@RestController("UserCategoryController")
@RequestMapping("/user/category")
@Api(tags = "分类相关的接口")
@Slf4j
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("查询分类接口")
    @GetMapping("/list")
    public Result<List<Category>>  getByType(Integer  type){

        if(type== null){
            List<Category> categories = categoryService.QueryBYType(type);
            return Result.success(categories);
        }
        log.info("查询的分类为：{}", type ==1? "菜品":"套餐");
        List<Category> categories = categoryService.QueryBYType(type);
        return Result.success(categories);
    }

}
